/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#include <stdio.h>
#include <tvm_runtime.h>
#include <tvmgen_text_angle_cls.h>

#include "uart.h"

// Header files generated by convert_image.py
#include "inputs.h"
#include "outputs.h"


int main(int argc, char** argv) {
  uart_init();
  printf("Starting text angle classification inference\n");
  struct tvmgen_text_angle_cls_outputs text_angle_cls_outputs = {
      .output = text_angle_cls_output,
  };
  struct tvmgen_text_angle_cls_inputs text_angle_cls_inputs = {
      .x = text_angle_cls_input,
  };

  tvmgen_text_angle_cls_run(&text_angle_cls_inputs, &text_angle_cls_outputs);

  // post process
  if(text_angle_cls_output[0] >= text_angle_cls_output[1]) {
    printf("The input picture is a horizontal picture, confidence is %.2f\n",text_angle_cls_output[0]);
  } else{
    printf("The input picture is a vertical picture, confidence is %.2f\n", text_angle_cls_output[1]);
  }

  // The FVP will shut down when it receives "EXITTHESIM" on the UART
  printf("EXITTHESIM\n");
  while (1 == 1)
    ;
  return 0;
}
